home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / TestTools / Sources / SITestClasses.cp < prev    next >
Encoding:
Text File  |  1996-11-19  |  11.7 KB  |  594 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SITestClasses.cp
  3.  
  4.     Contains:    Test code for SI-type classes
  5.  
  6.     Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #define qDebug 1
  11.  
  12. #include <GlobalNew.h>
  13. #include "SITestClasses.h"
  14.  
  15. #ifndef __LIBRARYMANAGERUTILITIES__
  16. #include <LibraryManagerUtilities.h>
  17. #endif
  18.  
  19. static unsigned short    gState;
  20.  
  21. /*******************************************************************************
  22. ** InitTestLibrary
  23. ********************************************************************************/
  24.  
  25. void InitTestLibrary()
  26. {
  27.     gState = 0;
  28. }
  29.  
  30. unsigned short GetStateValue()
  31. {
  32.     return gState;
  33. }
  34.  
  35. /*******************************************************************************
  36. ** Class TNVTest1
  37. ********************************************************************************/
  38.  
  39. #define knv1state1    0
  40. #define knv1state2    4
  41.  
  42. TNVTest1::TNVTest1()
  43. {
  44.     fField = gState++;
  45.     if (fField != knv1state1 && fField != knv1state2)
  46.         DebugBreak("TNVTest1::TNVTest1 - state not right");
  47. }
  48.  
  49. TNVTest1::~TNVTest1()
  50. {
  51.     switch (fField)
  52.     {
  53.         case knv1state1:
  54.             if (gState++ != fField + 3)
  55.                 DebugBreak("TNVTest1::~TNVTest1 - gState not correct");
  56.             break;
  57.             
  58.         case knv1state2:
  59.             if (gState++ != fField + 7)
  60.                 DebugBreak("TNVTest1::~TNVTest1 - gState not correct");
  61.             break;
  62.             
  63.         default:
  64.             gState += 1;
  65.             DebugBreak("TNVTest1::~TNVTest1 - fField not correct");
  66.     }
  67. }
  68.  
  69.  
  70. int TNVTest1::NVTest1(int a, int b)
  71. {
  72.     switch (fField)
  73.     {
  74.         case knv1state1:
  75.             if (a != 1 || b != 2)
  76.                 DebugBreak("TNVTest1::NVTest1 - arguments incorrect");
  77.             if (gState++ != fField + 1)
  78.                 DebugBreak("TNVTest1::NVTest1 - gState not right");
  79.             break;
  80.             
  81.         case knv1state2:
  82.             if (a != 5 || b != 6)
  83.                 DebugBreak("TNVTest1::NVTest1 - arguments incorrect");
  84.             if (gState++ != fField + 2)
  85.                 DebugBreak("TNVTest1::NVTest1 - gState not right");
  86.             break;
  87.             
  88.         default:
  89.             gState += 1;
  90.             DebugBreak("TNVTest1::NVTest1 - fField not right");
  91.     }
  92.     return a + b;
  93. }
  94.  
  95. int TNVTest1::NVTest2(int a, int b)
  96. {
  97.     switch (fField)
  98.     {
  99.         case knv1state1:
  100.             if (a != 3 || b != 4)
  101.                 DebugBreak("TNVTest1::NVTest2 - arguments incorrect");
  102.             if (gState++ != fField + 2)
  103.                 DebugBreak("TNVTest1::NVTest2 - gState not right");
  104.             break;
  105.             
  106.         case knv1state2:
  107.             if (a != 7 || b != 8)
  108.                 DebugBreak("TNVTest1::NVTest2 - arguments incorrect");
  109.             if (gState++ != fField + 3)
  110.                 DebugBreak("TNVTest1::NVTest2 - gState not right");
  111.             break;
  112.             
  113.         default:
  114.             gState += 1;
  115.             DebugBreak("TNVTest1::NVTest1 - fField not right");
  116.     }
  117.     return a - b;
  118. }
  119.  
  120. /*******************************************************************************
  121. ** Class TNVTest2
  122. ********************************************************************************/
  123.  
  124. #define knv2state    5
  125.  
  126. TNVTest2::TNVTest2()
  127. {
  128.     fField2 = gState++;
  129.     if (fField2 != knv2state)
  130.         DebugBreak("TNVTest2::TNVTest2 - state not right");
  131. }
  132.  
  133. TNVTest2::~TNVTest2()
  134. {
  135.     if (fField2 != knv2state)
  136.         DebugBreak("TNVTest2::~TNVTest2 - fField2 not right");
  137.     if (gState++ != fField2 + 5)
  138.         DebugBreak("TNVTest2::~TNVTest2 - state not right");
  139. }
  140.  
  141.  
  142. int TNVTest2::NVTest3(int a, int b)
  143. {
  144.     if (gState++ != knv2state + 3)
  145.         DebugBreak("TNVTest2::NVTest3 - state not right");
  146.     if (fField2 != knv2state)
  147.         DebugBreak("TNVTest2::NVTest3 - fField2 not right");
  148.     return a + b;
  149. }
  150.  
  151. int TNVTest2::NVTest4(int a, int b)
  152. {
  153.     if (gState++ != knv2state + 4)
  154.         DebugBreak("TNVTest2::NVTest4 - state not right");
  155.     if (fField2 != knv2state)
  156.         DebugBreak("TNVTest2::NVTest4 - fField2 not right");
  157.     return a + b;
  158. }
  159.  
  160. /*******************************************************************************
  161. ** Class TSITest1
  162. ********************************************************************************/
  163.  
  164. #define ksi1state1    12
  165.  
  166. TSITest1::TSITest1()
  167. {
  168.     fField = gState++;
  169.     if (fField != ksi1state1)
  170.         DebugBreak("TSITest1::TSITest1 - state not right");
  171. }
  172.  
  173. TSITest1::~TSITest1()
  174. {
  175.     switch (fField)
  176.     {
  177.         case ksi1state1:
  178.             if (gState++ != fField + 5)
  179.                 DebugBreak("TSITest1::~TSITest1 - gState not correct");
  180.             break;
  181.             
  182.         default:
  183.             gState += 1;
  184.             DebugBreak("TSITest1::~TSITest1 - fField not correct");
  185.             break;
  186.     }
  187. }
  188.  
  189. int TSITest1::VTest1(int a, int b)
  190. {
  191.     switch (fField)
  192.     {
  193.         case ksi1state1:
  194.             if (a != 13 || b != 14)
  195.                 DebugBreak("TSITest1::VTest1 - arguments incorrect");
  196.             if (gState++ != fField + 1)
  197.                 DebugBreak("TSITest1::VTest1 - gState not right");
  198.             break;
  199.             
  200.         default:
  201.             gState += 1;
  202.             DebugBreak("TSITest1::VTest1 - fField not right");
  203.             break;
  204.     }
  205.     return a + b;
  206. }
  207.  
  208. int TSITest1::VTest2(int a, int b)
  209. {
  210.     switch (fField)
  211.     {
  212.         case ksi1state1:
  213.             if (a != 15 || b != 16)
  214.                 DebugBreak("TSITest1::VTest2 - arguments incorrect");
  215.             if (gState++ != fField + 2)
  216.                 DebugBreak("TSITest1::VTest2 - gState not right");
  217.             break;
  218.             
  219.         default:
  220.             gState += 1;
  221.             DebugBreak("TSITest1::VTest2 - fField not right");
  222.             break;
  223.     }
  224.     return a - b;
  225. }
  226.  
  227. int TSITest1::NVTest1(int a, int b)
  228. {
  229.     switch (fField)
  230.     {
  231.         case ksi1state1:
  232.             if (a != 17 || b != 18)
  233.                 DebugBreak("TSITest1::NVTest1 - arguments incorrect");
  234.             if (gState++ != fField + 3)
  235.                 DebugBreak("TSITest1::NVTest1 - gState not right");
  236.             break;
  237.             
  238.         default:
  239.             gState += 1;
  240.             DebugBreak("TSITest1::NVTest1 - fField not right");
  241.             break;
  242.     }
  243.     return a + b;
  244. }
  245.  
  246. int TSITest1::NVTest2(int a, int b)
  247. {
  248.     switch (fField)
  249.     {
  250.         case ksi1state1:
  251.             if (a != 19 || b != 20)
  252.                 DebugBreak("TSITest1::NVTest2 - arguments incorrect");
  253.             if (gState++ != fField + 4)
  254.                 DebugBreak("TSITest1::NVTest2 - gState not right");
  255.             break;
  256.             
  257.         default:
  258.             gState += 1;
  259.             DebugBreak("TSITest1::NVTest2 - fField not right");
  260.             break;
  261.     }
  262.     return a - b;
  263. }
  264.  
  265. /*******************************************************************************
  266. ** Class TSITest2
  267. ********************************************************************************/
  268.  
  269. #define ksi2state1    18
  270.  
  271. ASLM_SCDECLARATION(TSITest2);
  272.  
  273. TSITest2::TSITest2()
  274. {
  275.     fField = gState++;
  276.     if (fField != ksi2state1)
  277.         DebugBreak("TSITest2::TSITest2 - state not right");
  278. }
  279.  
  280. TSITest2::~TSITest2()
  281. {
  282.     switch (fField)
  283.     {
  284.         case ksi2state1:
  285.             if (gState++ != fField + 5)
  286.                 DebugBreak("TSITest2::~TSITest2 - gState not correct");
  287.             break;
  288.             
  289.         default:
  290.             gState += 1;
  291.             DebugBreak("TSITest2::~TSITest2 - fField not correct");
  292.             break;
  293.     }
  294. }
  295.  
  296. int TSITest2::VTest1(int a, int b)
  297. {
  298.     switch (fField)
  299.     {
  300.         case ksi2state1:
  301.             if (a != 21 || b != 22)
  302.                 DebugBreak("TSITest2::VTest1 - arguments incorrect");
  303.             if (gState++ != fField + 1)
  304.                 DebugBreak("TSITest2::VTest1 - gState not right");
  305.             break;
  306.             
  307.         default:
  308.             gState += 1;
  309.             DebugBreak("TSITest2::VTest1 - fField not right");
  310.             break;
  311.     }
  312.     return a + b;
  313. }
  314.  
  315. int TSITest2::VTest2(int a, int b)
  316. {
  317.     switch (fField)
  318.     {
  319.         case ksi2state1:
  320.             if (a != 23 || b != 24)
  321.                 DebugBreak("TSITest2::VTest2 - arguments incorrect");
  322.             if (gState++ != fField + 2)
  323.                 DebugBreak("TSITest2::VTest2 - gState not right");
  324.             break;
  325.             
  326.         default:
  327.             gState += 1;
  328.             DebugBreak("TSITest2::VTest2 - fField not right");
  329.             break;
  330.     }
  331.     return a - b;
  332. }
  333.  
  334. int TSITest2::NVTest1(int a, int b)
  335. {
  336.     switch (fField)
  337.     {
  338.         case ksi2state1:
  339.             if (a != 25 || b != 26)
  340.                 DebugBreak("TSITest2::NVTest1 - arguments incorrect");
  341.             if (gState++ != fField + 3)
  342.                 DebugBreak("TSITest2::NVTest1 - gState not right");
  343.             break;
  344.             
  345.         default:
  346.             gState += 1;
  347.             DebugBreak("TSITest2::NVTest1 - fField not right");
  348.             break;
  349.     }
  350.     return a + b;
  351. }
  352.  
  353. int TSITest2::NVTest2(int a, int b)
  354. {
  355.     switch (fField)
  356.     {
  357.         case ksi2state1:
  358.             if (a != 27 || b != 28)
  359.                 DebugBreak("TSITest2::NVTest2 - arguments incorrect");
  360.             if (gState++ != fField + 4)
  361.                 DebugBreak("TSITest2::NVTest2 - gState not right");
  362.             break;
  363.             
  364.         default:
  365.             gState += 1;
  366.             DebugBreak("TSITest2::NVTest2 - fField not right");
  367.             break;
  368.     }
  369.     return a - b;
  370. }
  371.  
  372. /*******************************************************************************
  373. ** Class TSITest3
  374. ********************************************************************************/
  375.  
  376. #define ksi3state1    24
  377. #define ksi3state2    30
  378.  
  379. ASLM_SCDECLARATION(TSITest3);
  380.  
  381. TSITest3::TSITest3()
  382. {
  383.     fField = gState++;
  384.     if (fField != ksi3state1 && fField != ksi3state2)
  385.         DebugBreak("TSITest3::TSITest3 - state not right");
  386. }
  387.  
  388. TSITest3::~TSITest3()
  389. {
  390.     switch (fField)
  391.     {
  392.         case ksi3state1:
  393.             if (gState++ != fField + 5)
  394.                 DebugBreak("TSITest3::~TSITest3 - gState not correct");
  395.             break;
  396.             
  397.         case ksi3state2:
  398.             if (gState++ != fField + 5)
  399.                 DebugBreak("TSITest3::~TSITest3 - gState not correct");
  400.             break;
  401.             
  402.         default:
  403.             gState += 1;
  404.             DebugBreak("TSITest3::~TSITest3 - fField not correct");
  405.             break;
  406.     }
  407. }
  408.  
  409. int TSITest3::VTest1(int a, int b)
  410. {
  411.     switch (fField)
  412.     {
  413.         case ksi3state1:
  414.             if (a != 29 || b != 30)
  415.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  416.             if (gState++ != fField + 1)
  417.                 DebugBreak("TSITest3::VTest1 - gState not right");
  418.             break;
  419.             
  420.         case ksi3state2:
  421.             if (a != 37 || b != 38)
  422.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  423.             if (gState++ != fField + 1)
  424.                 DebugBreak("TSITest3::VTest1 - gState not right");
  425.             break;
  426.             
  427.         default:
  428.             gState += 1;
  429.             DebugBreak("TSITest3::VTest1 - fField not right");
  430.             break;
  431.     }
  432.     return a + b;
  433. }
  434.  
  435. int TSITest3::VTest2(int a, int b)
  436. {
  437.     switch (fField)
  438.     {
  439.         case ksi3state1:
  440.             if (a != 31 || b != 32)
  441.                 DebugBreak("TSITest3::VTest2 - arguments incorrect");
  442.             if (gState++ != fField + 2)
  443.                 DebugBreak("TSITest3::VTest2 - gState not right");
  444.             break;
  445.             
  446.         case ksi3state2:
  447.             if (a != 39 || b != 40)
  448.                 DebugBreak("TSITest3::VTest1 - arguments incorrect");
  449.             if (gState++ != fField + 2)
  450.                 DebugBreak("TSITest3::VTest1 - gState not right");
  451.             break;
  452.             
  453.         default:
  454.             gState += 1;
  455.             DebugBreak("TSITest3::VTest2 - fField not right");
  456.             break;
  457.     }
  458.     return a - b;
  459. }
  460.  
  461. int TSITest3::NVTest1(int a, int b)
  462. {
  463.     switch (fField)
  464.     {
  465.         case ksi3state1:
  466.             if (a != 33 || b != 34)
  467.                 DebugBreak("TSITest3::NVTest1 - arguments incorrect");
  468.             if (gState++ != fField + 3)
  469.                 DebugBreak("TSITest3::NVTest1 - gState not right");
  470.             break;
  471.             
  472.         case ksi3state2:
  473.             if (a != 41 || b != 42)
  474.                 DebugBreak("TSITest3::NVTest1 - arguments incorrect");
  475.             if (gState++ != fField + 3)
  476.                 DebugBreak("TSITest3::NVTest1 - gState not right");
  477.             break;
  478.             
  479.         default:
  480.             gState += 1;
  481.             DebugBreak("TSITest3::NVTest1 - fField not right");
  482.             break;
  483.     }
  484.     return a + b;
  485. }
  486.  
  487. int TSITest3::NVTest2(int a, int b)
  488. {
  489.     switch (fField)
  490.     {
  491.         case ksi3state1:
  492.             if (a != 35 || b != 36)
  493.                 DebugBreak("TSITest3::NVTest2 - arguments incorrect");
  494.             if (gState++ != fField + 4)
  495.                 DebugBreak("TSITest3::NVTest2 - gState not right");
  496.             break;
  497.             
  498.         case ksi3state2:
  499.             if (a != 43 || b != 44)
  500.                 DebugBreak("TSITest3::NVTest2 - arguments incorrect");
  501.             if (gState++ != fField + 4)
  502.                 DebugBreak("TSITest3::NVTest2 - gState not right");
  503.             break;
  504.             
  505.         default:
  506.             gState += 1;
  507.             DebugBreak("TSITest3::NVTest2 - fField not right");
  508.             break;
  509.     }
  510.     return a - b;
  511. }
  512.  
  513. /*******************************************************************************
  514. ** Class TSITest4
  515. ********************************************************************************/
  516.  
  517. ASLM_SCDECLARATION(TSITest4);
  518.  
  519. TSITest4::TSITest4()
  520. {
  521.     fField = 0;
  522. }
  523.  
  524. TSITest4::~TSITest4()
  525. {}
  526.  
  527. int TSITest4::VTest1(int a, int b)
  528. {
  529.     return a + b;
  530. }
  531.  
  532. int TSITest4::VTest2(int a, int b)
  533. {
  534.     return a - b;
  535. }
  536.  
  537. int TSITest4::VTest3(int a, int b)
  538. {
  539.     return a + b;
  540. }
  541.  
  542. int TSITest4::VTest4(int a, int b)
  543. {
  544.     return a - b;
  545. }
  546.  
  547. int TSITest4::NVTest1(int a, int b)
  548. {
  549.     return a + b;
  550. }
  551.  
  552. int TSITest4::NVTest2(int a, int b)
  553. {
  554.     return a - b;
  555. }
  556.  
  557. /*******************************************************************************
  558. ** Class TSITest5
  559. ********************************************************************************/
  560.  
  561. TSITest5::TSITest5()
  562. {
  563.     fField2 = 0;
  564. }
  565.  
  566. TSITest5::~TSITest5()
  567. {}
  568.  
  569. int TSITest5::VTest1(int a, int b)
  570. {
  571.     return a - b;
  572. }
  573.  
  574. int TSITest5::VTest2(int a, int b)
  575. {
  576.     return a + b;
  577. }
  578.  
  579. int TSITest5::VTest4(int a, int b)
  580. {
  581.     return a - b;
  582. }
  583.  
  584. int TSITest5::NVTest1(int a, int b)
  585. {
  586.     return a + b;
  587. }
  588.  
  589. int TSITest5::NVTest2(int a, int b)
  590. {
  591.     return a - b;
  592. }
  593.  
  594.